function samePermute(nums) {
    let res = []
    const dfs = (path, sameIndex) => {
        if(nums.length == path.length) {
            res.push(path)
            return
        } 
        // control控制相同元素不能继续排列
        // sameIndex相同元素不能作为主分支元素
        let control = []
        for(let i = 0;i < nums.length;i++) {
            if(sameIndex.includes(i) || conrtol.includes(nums[i])) continue
            control.push(nums[i])
            dfs(path.concat(nums[i]),sameIndex.concat(i))
        }
    }
    dfs([],[])
    return res
}
console.log(samePermute([1,2,2]));

// 时间复杂度：O(n! * n)
// 空间复杂度：O(n)